package com.thingsgrid.device.monitor.controller;
import com.thingsgrid.device.entity.Product;
import com.thingsgrid.device.monitor.service.AlarmMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *告警监控
 */
@AllArgsConstructor
@RestController
@RequestMapping("/alarm_monitor")
@Api(value = "告警监控", tags = "告警监控")
public class AlarmMonitorController<w> {

	private AlarmMonitorService alarmMonitorService;


	/**
	 *
	 *告警列表
	 * @author 陈学栋
	 * @date 2019/9/5 11:18
	 */
	@PostMapping("/findAlarmMonitorList")
	@ApiOperation(value = "查询告警列表", notes = "查询告警列表", position = 1)
	public R<Map<String, Object>> findListByNameAndType(@RequestParam String startTime, @RequestParam String endTime,
														@RequestParam String alarmGrade, @RequestParam Integer current,
														@RequestParam Integer size, @RequestParam String deviceId){
		Map<String, Object> map =  alarmMonitorService.findAlarmMonitorList(startTime,endTime,alarmGrade,deviceId,current,size);
		return R.data(map);
	}

	/**
	 *
	 *查询产品名称
	 * @author 陈学栋
	 * @date 2019/9/9 15:06
	 */
	@GetMapping("/findProductName")
	@ApiOperation(value = "告警统计", notes = "告警统计", position = 2)
	public R<List<Product>> findProductName(){
		List<Product> list =  alarmMonitorService.findProductName();
		return R.data(list);
	}

	/**
	 *
	 *告警统计
	 * @author 陈学栋
	 * @date 2019/9/5 11:18
	 */
	@GetMapping("/alarmStatistics")
	@ApiOperation(value = "告警统计", notes = "告警统计", position = 2)
	public R<Map<String, String>> selectAlarmStatistics(){
		Map<String, String> map = alarmMonitorService.alarmStatistics();
		return R.data(map);
	}

	/**
	 *
	 *批量清除告警
	 * @author 陈学栋
	 * @date 2019/9/5 13:06
	 */
	@PostMapping("/delete_alarmMonitor")
	@ApiOperation(value = "删除告警", notes = "删除告警", position = 3)
	public R deleteMertrics(String alarmId){
		return R.status(alarmMonitorService.deleteAlarmMonitor(alarmId));
	}

	/**
	 *
	 *告警信息的确认
	 * @author 陈学栋
	 * @date 2019/9/5 13:23
	 */
	@PostMapping("/confirm_alarmMonitor")
	@ApiOperation(value = "告警信息的确认", notes = "告警信息的确认", position = 4)
	public R confirmAlarmMonitor(String alarmId){
		return R.status(alarmMonitorService.confirmAlarmMonitor(alarmId));
	}
}
